#ifndef _TASKQUEUE_H_
#define _TASKQUEUE_H_


#include <mutex>
#include <condition_variable>
#include <queue>

using std::queue;
using std::mutex;
using std::unique_lock;
using std::condition_variable;

class Task;

using ElemType = Task *;

class TaskQueue
{
public:
    TaskQueue(size_t capa);
    ~TaskQueue();

    void push(ElemType value);
    ElemType pop();

    bool empty() const;
    bool full() const;

    void wakeup();

private:
    size_t _capacity;
    queue<ElemType> _que;
    mutex _mutex;
    condition_variable _notEmpty;
    condition_variable _notFull;
    bool _flag;
};

#endif


